<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改订单')" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-customer-edit" th:object="${order}">
		<div class="form-group">
			<input id="orderId" name="orderId" th:field="*{orderId}"  type="hidden">
			<label class="col-sm-3 control-label">客户：</label>
			<div class="col-sm-8">
				<div class="input-group">
					<input name="customerId"  id="treeId" type="hidden" th:field="*{customerId}">
					<input name="name" onclick="selectCustomerTree()" id="treeName" type="text" placeholder="请选择客户" class="form-control" required autocomplete="off" th:field="*{name}">
					<span class="input-group-addon"><i class="fa fa-search"></i></span>
				</div>
			</div>
		</div>
		<div class="form-group draggable">
			<label class="col-sm-3 control-label">签约时间：</label>
			<div class="col-sm-8">
				<div class="input-group date">
					<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
					<input type="text" id="signTime" name="signTime" class="form-control" value="" th:value="${#dates.format(order.signTime,'yyyy-MM-dd')}">
				</div>
			</div>
		</div>
		<!--<div class="form-group">
			<label class="col-sm-3 control-label">客服经理：</label>
			<div class="col-sm-8">
				<div class="input-group">
					<input name="managerId"  id="treeUserId" type="hidden" th:field="*{managerId}">
					<input name="managerName" onclick="selectUserTree()" id="treeUserName" type="text" placeholder="请选择客服经理" class="form-control" required autocomplete="off" th:field="*{managerName}">
					<span class="input-group-addon"><i class="fa fa-search"></i></span>
				</div>
			</div>
		</div>-->
		<div class="form-group">
			<label class="col-sm-3 control-label">贷款方式：</label>
			<div class="col-sm-8">
				<select id="dkType" name="dkType" class="form-control m-b" th:with="type=${@dict.getType('dkType')}" th:field="*{dkType}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">还款方式：</label>
			<div class="col-sm-8">
				<select id="hkType" name="hkType" class="form-control m-b" th:with="type=${@dict.getType('hkType')}" th:field="*{hkType}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">申请金额：</label>
			<div class="col-sm-8">
				<div class="input-group" style="width:100%">
					<input id="applyMoney" name="applyMoney" class="form-control" type="text" th:field="*{applyMoney}">
					<span class="input-group-btn">
								<button class="btn btn-primary" type="button">万元</button>
							</span>
					</input>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">还款期数：</label>
			<div class="col-sm-8">
				<div class="input-group" style="width:100%">
					<input id="period" name="period" class="form-control" type="text" th:field="*{period}">
					<span class="input-group-btn">
								<button class="btn btn-primary" type="button">期</button>
							</span>
					</input>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">信息服务费：</label>
			<div class="col-sm-8">
				<div class="input-group" style="width:100%">
					<input id="serviceMoney" name="serviceMoney" class="form-control" type="text" th:field="*{serviceMoney}">
					<span class="input-group-btn">
								<button class="btn btn-primary" type="button">元</button>
							</span>
					</input>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">备注：</label>
			<div class="col-sm-8">
				<textarea name="remark" autocomplete="off" maxlength="500" class="form-control" rows="3" th:text="*{remark}"></textarea>
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
	var prefix = ctx + "crm/order"
	$("#form-order-add").validate({
		rules:{
			xxxx:{
				required:true,
			},
		},
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			$.operate.save(prefix + "/edit", $('#form-customer-edit').serialize());
		}
	}

	$(".input-group.date").datetimepicker({
		format: "yyyy-mm-dd",
		minView: "month",
		autoclose: true
	});

	/*选择客户树*/
	function selectCustomerTree() {
		var treeId = $("#treeId").val();
		var url = ctx + "crm/customer/selectCustomerTree";
		var options = {
			title: '选择客户',
			width: "310",
			height: "380",
			url: url,
			callBack: doSubmit
		};
		$.modal.openOptions(options);
	}

	function doSubmit(index, layero){
		var tree = layero.find("iframe")[0].contentWindow.$._tree;
		var body = layer.getChildFrame('body', index);
		$("#treeId").val(body.find('#treeId').val());
		$("#treeName").val(body.find('#treeName').val());
		layer.close(index);
	}

	/*选择用户树*/
	function selectUserTree() {
		var treeId = $("#treeId").val();
		var url = ctx + "system/user/selectUserTree";
		var options = {
			title: '选择用户',
			width: "310",
			height: "380",
			url: url,
			callBack: doUserSubmit
		};
		$.modal.openOptions(options);
	}

	function doUserSubmit(index, layero){
		var tree = layero.find("iframe")[0].contentWindow.$._tree;
		var body = layer.getChildFrame('body', index);
		$("#treeUserId").val(body.find('#treeId').val());
		$("#treeUserName").val(body.find('#treeName').val());
		layer.close(index);
	}
</script>
</body>
</html>
